package servlet.admin.music;

import com.alibaba.fastjson.JSON;
import pojo.Result;
import service.MusicMngService;
import service.impl.MusicMngServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 作者：杨晋
 */

@WebServlet("/admin/deleteMusicServlet")
public class DeleteSongServlet extends HttpServlet {
    MusicMngService musicMngService = new MusicMngServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String songId = req.getParameter("songId");
        boolean flag = musicMngService.deleteUploadedSong(Integer.parseInt(songId));
        Result result = new Result();
        if (flag) {
            result = Result.success();
        } else {
            result = Result.error("删除失败");
        }
        resp.getWriter().write(JSON.toJSONString(result));



    }
}